window.onload = function () {
    // alert("index");
    authenticate();
    fillingMain(1, "questions", 6);
    fillingHotTopic("questions", 4);
    appendCarousel(4);
};

function appendCarousel(number) {
    $.ajax({
        url: "/carousel/" + number,
        dataType: "json",
        contentType: "application/json;charset=utf-8",
        type: "GET",
        success: function (response) {
            $(".carousel-indicators").empty();
            $(".carousel-inner").empty();
            var bonus=null;
            for (var i = 0; i < response.data.length; i++) {
                if(i===0){
                    bonus="active";
                }else {
                    bonus="";
                }
                var info=" <li data-target=\"#carousel-example-generic\" data-slide-to=\"" + i + "\" class=\"" + bonus + "\"></li>";
                $(".carousel-indicators").append(info);
                var info_ = "<div class=\"item"+' '+bonus + "\"'>\n" +
                    "              <a href=\"" + "/news/"+response.data[i].id + "\" style='position:relative;'>\n" +
                    "                  <img src=\"" + response.data[i].imageUrl + "\" style=\"width: 360px;height: 360px;\" alt=\"#\">\n" +
                    "                       <div style='position:absolute;top:175px;height: 40px;width:100%;background-color: rgba(0,0,0,0.5);'>" +
                    "                           <p style='color: #fff;text-align: left;font-weight: bold;text-indent: 5px;'>" + response.data[i].title + "</p>"+
                    "                       </div>"+
                    "              </a>\n" +
                    "         </div>";
                $(".carousel-inner").append(info_);
                //TODO 2020-03-11 轮播图底下的标题！
            }
        },
        error: function (request) {
            console.log(request);
        }
    });
    $(".carousel-inner")
}


